package com.thti.mecool.client.command.result.plan;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.thti.mecool.client.base.BaseActivity;
import com.thti.mecool.client.base.Cache;
import com.thti.mecool.client.base.HandlerConstant;
import com.thti.mecool.client.command.ICommand;
import com.thti.mecool.client.model.biz.TaskManageBizImpl;
import com.thti.mecool.client.protocol.plan.FilesProtocol;
import com.thti.mecool.client.protocol.plan.FilesProtocolResult;
import com.thti.mecool.client.service.Protocol;
import com.thti.mecool.client.util.Util;

public class UploadImageCommand implements ICommand {

	@Override
	public void doCommand(Object o) {
		FilesProtocolResult filesProtocolResult=(FilesProtocolResult)o;
		if(filesProtocolResult.getStatus()==1){
			TaskManageBizImpl bizImpl = new TaskManageBizImpl(Cache.getmContext());
			List<FilesProtocol> list=filesProtocolResult.getFiles();
			Util.print("**************************");
			if(list.size()>0){ 
				List<Map<String,Object[]>> listMap=new ArrayList<Map<String,Object[]>>();
				for (int i = 0; i < list.size(); i++) {
					Map<String,Object[]> map=new HashMap<String, Object[]>();
					map.put(HandlerConstant.UPDATE_TASKMANAGE_SQL, new Object[]{list.get(i).getName(),1
							,list.get(i).getPlan_id(),list.get(i).getPlan_project_id(),list.get(i).getPlan_job_id()
							,list.get(i).getStep_id()});
					listMap.add(map);
				}
				bizImpl.updateByImage(listMap);
			}
			System.out.println("UploadImgCommand");
			BaseActivity.setDataFlag(HandlerConstant.UploadImgCommand);
		}else{
			
		}
		
		
	}

	@Override
	public String getCommandID() {
		// TODO Auto-generated method stub
		return Protocol.getUpload;
	}

	@Override
	public Class<?> getCommandClass() {
		// TODO Auto-generated method stub
		return FilesProtocolResult.class;
	}

}
